﻿using System;
using System.Diagnostics;
using Microsoft.Xna.Framework;
using Terraria.GameContent.UI.Elements;
using Terraria.Localization;
using Terraria.UI;

namespace Terraria.ModLoader.UI
{
	// Token: 0x0200027E RID: 638
	internal class UIEnterPassphraseMenu : UIState
	{
		// Token: 0x06001A15 RID: 6677 RVA: 0x00427A5C File Offset: 0x00425C5C
		public override void OnInitialize()
		{
			UIElement uielement = new UIElement();
			uielement.Width.Set(0f, 0.8f);
			uielement.MaxWidth.Set(600f, 0f);
			uielement.Top.Set(220f, 0f);
			uielement.Height.Set(-220f, 1f);
			uielement.HAlign = 0.5f;
			UIPanel uipanel = new UIPanel();
			uipanel.Width.Set(0f, 1f);
			uipanel.Height.Set(-110f, 1f);
			uipanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
			uipanel.PaddingTop = 0f;
			uielement.Append(uipanel);
			this.uITextPanel = new UITextPanel<string>(Language.GetTextValue("tModLoader.MBPublishEnterPassphrase"), 0.8f, true);
			this.uITextPanel.HAlign = 0.5f;
			this.uITextPanel.Top.Set(-35f, 0f);
			this.uITextPanel.SetPadding(15f);
			this.uITextPanel.BackgroundColor = new Color(73, 94, 171);
			uielement.Append(this.uITextPanel);
			UITextPanel<string> uitextPanel = new UITextPanel<string>(Language.GetTextValue("UI.Back"), 1f, false);
			uitextPanel.Width.Set(-10f, 0.5f);
			uitextPanel.Height.Set(25f, 0f);
			uitextPanel.VAlign = 1f;
			uitextPanel.Top.Set(-65f, 0f);
			uitextPanel.OnMouseOver += UICommon.FadedMouseOver;
			uitextPanel.OnMouseOut += UICommon.FadedMouseOut;
			uitextPanel.OnClick += this.BackClick;
			uielement.Append(uitextPanel);
			UITextPanel<string> uitextPanel2 = new UITextPanel<string>(Language.GetTextValue("UI.Submit"), 1f, false);
			uitextPanel2.CopyStyle(uitextPanel);
			uitextPanel2.HAlign = 1f;
			uitextPanel2.OnMouseOver += UICommon.FadedMouseOver;
			uitextPanel2.OnMouseOut += UICommon.FadedMouseOut;
			uitextPanel2.OnClick += this.OKClick;
			uielement.Append(uitextPanel2);
			UITextPanel<string> uitextPanel3 = new UITextPanel<string>(Language.GetTextValue("tModLoader.MBPublishVisitWebsiteForPassphrase"), 1f, false);
			uitextPanel3.CopyStyle(uitextPanel);
			uitextPanel3.Width.Set(0f, 1f);
			uitextPanel3.Top.Set(-20f, 0f);
			uitextPanel3.OnMouseOver += UICommon.FadedMouseOver;
			uitextPanel3.OnMouseOut += UICommon.FadedMouseOut;
			uitextPanel3.OnClick += this.VisitRegisterWebpage;
			uielement.Append(uitextPanel3);
			this.passcodeTextField = new UIInputTextField(Language.GetTextValue("tModLoader.MBPublishPastePassphrase"));
			this.passcodeTextField.HAlign = 0.5f;
			this.passcodeTextField.VAlign = 0.5f;
			this.passcodeTextField.Left.Set(-100f, 0f);
			this.passcodeTextField.OnTextChange += this.OnTextChange;
			uipanel.Append(this.passcodeTextField);
			base.Append(uielement);
		}

		// Token: 0x06001A16 RID: 6678 RVA: 0x000127EE File Offset: 0x000109EE
		private void OKClick(UIMouseEvent evt, UIElement listeningElement)
		{
			Main.PlaySound(10, -1, -1, 1, 1f, 0f);
			ModLoader.modBrowserPassphrase = this.passcodeTextField.currentString.Trim();
			Main.SaveSettings();
			Main.menuMode = this.gotoMenu;
		}

		// Token: 0x06001A17 RID: 6679 RVA: 0x0001282B File Offset: 0x00010A2B
		private void BackClick(UIMouseEvent evt, UIElement listeningElement)
		{
			Main.PlaySound(11, -1, -1, 1, 1f, 0f);
			Main.menuMode = this.gotoMenu;
		}

		// Token: 0x06001A18 RID: 6680 RVA: 0x0001284D File Offset: 0x00010A4D
		private void VisitRegisterWebpage(UIMouseEvent evt, UIElement listeningElement)
		{
			Main.PlaySound(10, -1, -1, 1, 1f, 0f);
			Process.Start(this.registerURL);
		}

		// Token: 0x06001A19 RID: 6681 RVA: 0x00006B58 File Offset: 0x00004D58
		private void OnTextChange(object sender, EventArgs e)
		{
		}

		// Token: 0x06001A1A RID: 6682 RVA: 0x00012870 File Offset: 0x00010A70
		internal void SetGotoMenu(int gotoMenu)
		{
			this.gotoMenu = gotoMenu;
		}

		// Token: 0x04001765 RID: 5989
		private string registerURL = "http://javid.ddns.net/tModLoader/register.php";

		// Token: 0x04001766 RID: 5990
		public UITextPanel<string> uITextPanel;

		// Token: 0x04001767 RID: 5991
		internal UIInputTextField passcodeTextField;

		// Token: 0x04001768 RID: 5992
		private int gotoMenu;
	}
}
